<template>
    <div>
        <city-header></city-header>
        <city-search :cities='cities'></city-search>
        <city-list :cities='cities' :hotCities="hotCities" :letter="letter"></city-list>
        <city-alphabet :cities='cities' @change="handleLetterChange"></city-alphabet>
    </div>
    
</template>
<script>
import cityHeader from './components/header'
import citySearch from './components/search'
import cityList from './components/List'
import cityAlphabet from './components/alphabet'
import axios from 'axios'
export default {
    name:'city',
    components:{
        cityHeader,
        citySearch,
        cityList,
        cityAlphabet
    },
    data(){
        return{
            hotCities:[],
            cities:{},
            letter:""
        }
    },
    mounted(){
        //AJAX数据的获取
        this.getCityInfo();
    },
    methods:{
        getCityInfo(){
            axios.get('/api/city.json').then(this.getCityInfoSucc);
        },
        getCityInfoSucc(res){
            console.log(res);
            res=res.data;
            if(res.ret&&res.data){
                const data=res.data;
                this.hotCities=data.hotCities;
                this.cities=data.cities;
            }
        },
        handleLetterChange(letter){
        //    console.log(letter);
           this.letter=letter;
        }
    }
}
</script>
<style lang="stylus" scoped>

</style>
